package com.ruike.alisurface.ui.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.ruike.alisurface.R;
import com.voodoo.lib_utils.imageLoader.ImageLoader;

/**
 * Author: voodoo
 * CreateDate: 2020-05-19 019下午 04:04
 * Description: 卡充值二维码扫码弹窗
 */
public class CardTopupZxingDialog {

    Context context;

    String cardNumber; // 卡号
    String priceStr; // 充值价格
    String time; // 订单生成时间
    String snStr; // 机器的SN
    String imgUrlPath = ""; // 二维码图片

    public CardTopupZxingDialog(Context context) {
        this.context = context;
    }

    public void setCardNumber(String cardNumber) {
        this.cardNumber = cardNumber;
    }

    public void setPriceStr(String priceStr) {
        this.priceStr = priceStr;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public void setSnStr(String snStr) {
        this.snStr = snStr;
    }

    public void setImgUrlPath(String imgUrlPath) {
        this.imgUrlPath = imgUrlPath == null ? "" : imgUrlPath;
    }

    public void showDialog() {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View layout = layoutInflater.inflate(R.layout.dialog_card_topup_zxing, null);

        ImageView qrcodeImgv = layout.findViewById(R.id.dialogTopupCard_qrcode_imgv);
        ImageLoader.loadImage(context, imgUrlPath, qrcodeImgv);

        CustomDialog.Builder builder = new CustomDialog.Builder(context);
        builder.setTitle("扫码充值");
        builder.setContentView(layout);
        builder.setNegativeButton("取消充值", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO 取消订单，请求接口，等待后台开发接口
            }
        });
        builder.create().show();
    }


}
